package com.dianxin.smartpark.web.park;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.tree.Tree;
import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.smartpark.dao.qo.park.SmartParkAreaQO;
import com.dianxin.smartpark.service.park.SmartParkAreaService;
import com.dianxin.smartpark.service.vo.park.SmartParkAreaVO;
import com.dianxin.sso.client.annotation.RecordLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 区域管理
 * 
 * @author chenjiasong
 * @date 2021-08-19
 */
@RestController
@RequestMapping("/smartpark/area")
public class SmartParkAreaController
{
    @Resource
    private SmartParkAreaService smartParkAreaService;

    /**
     * 查询区域管理列表
     */
    @GetMapping("/list")
    @SaCheckPermission("/smartpark/area/list")
    public CommonResponseBody<List<SmartParkAreaVO>>  list(SmartParkAreaQO qo)
    {
        return smartParkAreaService.selectSmartParkAreaList(qo);
    }

    /**
     * 查询区域管理树结构
     */
    @GetMapping("/tree")
    @SaCheckPermission("/smartpark/area/list")
    public CommonResponseBody<List<Tree<String>>>  tree(SmartParkAreaQO qo)
    {
        return smartParkAreaService.selectSmartParkAreaTree(qo);
    }


    /**
     * 获取区域管理详细信息
     */
    @GetMapping(value = "/getInfo")
    @SaCheckPermission("/smartpark/area/getInfo")
    public CommonResponseBody<SmartParkAreaVO> getInfo(SmartParkAreaQO qo)
    {
        return smartParkAreaService.selectSmartParkArea(qo);
    }

    /**
     * 新增区域管理
     */
    @PostMapping("/add")
    @SaCheckPermission("/smartpark/area/add")
    @RecordLog(name = "新增区域")
    public  CommonResponseBody<Boolean> add(@RequestBody SmartParkAreaVO vo)
    {
        return smartParkAreaService.insertSmartParkArea(vo);
    }

    /**
     * 修改区域管理
     */
    @PutMapping("/edit")
    @SaCheckPermission("/smartpark/area/edit")
    @RecordLog(name = "修改区域")
    public  CommonResponseBody<Boolean> edit(@RequestBody SmartParkAreaVO vo)
    {
        return smartParkAreaService.updateSmartParkArea(vo);
    }

    /**
     * 删除区域管理
     */
	@DeleteMapping("/remove")
    @SaCheckPermission("/smartpark/area/remove")
    @RecordLog(name = "删除区域")
    public  CommonResponseBody<Boolean> remove(@RequestBody SmartParkAreaVO vo)
    {
        return smartParkAreaService.deleteSmartParkArea(vo);
    }
}
